//
//  UIColor+LYAdd.m
//  LYDevelopKit
//
//  Created by 李阳 on 2018/5/25.
//

#import "UIColor+LYAdd.h"
#import "LYUIMacros.h"

LYSYNTH_DUMMY_CLASS(UIColor_LYAdd)

/// 颜色
inline UIColor *LYRGBColor(CGFloat red, CGFloat green, CGFloat blue)
{
    return LYRGBAColor(red, green, blue, 1.0);
}
/// 颜色
inline UIColor *LYRGBAColor(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)
{
    return [UIColor colorWithRed:(red)/255.0 green:(green)/255.0 blue:(blue)/255.0 alpha:alpha];
}


@implementation UIColor (LYAdd)

+ (UIColor *)colorWithHexValue:(uint32_t)value
{
    return [UIColor colorWithHexValue:value alpha:1.0];
}
+ (UIColor *)colorWithHexValue:(uint32_t)value alpha:(CGFloat)alpha
{
    float red = ((float)((value & 0xFF0000) >> 16))/255.0;
    float green = ((float)((value & 0xFF00) >> 8))/255.0;
    float blue = ((float)(value & 0xFF))/255.0;
    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
}
- (NSString *)componentsString
{
    CGFloat r, g, b, a;
    [self getRed:&r green:&g blue:&b alpha:&a];
    return [NSString stringWithFormat:@"red:%.2f green:%.2f blue:%.2f alpha:%.2f", r*255, g*255, b*255, a];
}
@end
